package cn.gzsxt.music.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.gzsxt.music.query.ModularQueryObject;
@Mapper
public interface ModularMapper {
	/**
	 * 根据条件查询结果
	 * 
	 * @param qo 条件对象
	 * @return 结果集
	 */
	@Select("select * from tb_modular limit #{beginIndex},#{rows}")
	List<Map<String, Object>> selectModularListByCondition(ModularQueryObject qo);

	/**
	 * 根据条件查询总数
	 * 
	 * @param qo 条件对象
	 * @return 总数
	 */
	@Select("select count(*) from tb_modular")
	Long selectModularTotalByCondition(ModularQueryObject qo);

	/**
	 * 插入操作
	 * 
	 * @param params
	 * @return
	 */
	@Insert("insert into tb_modular (modular_name) values (#{modular_name})")
	// @Options(useGeneratedKeys=true,keyProperty="modular_id")
	int insert(Map<String, Object> params);

	/**
	 * 删除指定id的模块
	 * 
	 * @param modular_id
	 * @return
	 */
	@Delete("delete from tb_modular where modular_id = #{modular_id}")
	int deleteModularById(@Param("modular_id") Long modular_id);

	/**
	 * 	修改指定id的模块名称
	 * @param params
	 * @return
	 */
	@Update("update tb_modular set modular_name = #{modular_name} where modular_id = #{modular_id}")
	int update(Map<String, Object> params);
	/**
	 * 查询出所有的模块
	 * @return
	 */
	@Select("select modular_id id,modular_name text from tb_modular")
	List<Map<String, Object>> selectAllModulars();
	
	@Select("select modular_id id,modular_name text from tb_modular where modular_id = #{modular_id}")
	List<Map<String, Object>> selectAllModularsById(@Param("modular_id") Long modular_id);
}
